#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int wiggleMaxLength(vector<int>& nums) {
        int n = nums.size();
        vector<vector<int>> dp(n, vector<int>(2, 1));
        int ret = 1;
        for (int i = 1; i < n; i++)
        {
            for (int j = 0; j < i; j++)
            {
                if (nums[j] < nums[i])
                {

                    dp[i][0] = max(dp[j][1] + 1, dp[i][0]);

                }
                else if (nums[j] > nums[i])
                {
                    dp[i][1] = max(dp[j][0] + 1, dp[i][1]);
                }
            }

            ret = max(ret, max(dp[i][0], dp[i][1]));
        }


        return ret;


    }
};